package per.ethan.ssm.config;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;

import java.io.File;

/**
 * @author Ethan
 * @date 2020/04/28 10:04
 */
public class SpringApplication {

    public static void run() {
        // 操作系统的临时目录
        File file = new File(System.getProperty("java.io.tmpdir"));

        Tomcat tomcat = new Tomcat();
        tomcat.setPort(8080);
        tomcat.addWebapp("/", file.getAbsolutePath());
        try {
            tomcat.start();
            tomcat.getServer().await();
        } catch (LifecycleException e) {
            e.printStackTrace();
        }
    }

}
